package com.pubinfo.passbook.common.model.dto.financial;

import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

@Data
@ApiModel(value = "InvoiceResult", description = "票据源接口返回参数")
public class InvoiceResult<T> implements Serializable {
  @JSONField(name = "success")
  @ApiModelProperty(value = "是否成功")
  private Boolean success;
  @ApiModelProperty(value = "结果码")
  @JSONField(name = "resultCode")
  private String resultCode;
  
  @JSONField(name = "resultMsg")
  @ApiModelProperty(value = "结果消息")
  private Object resultMsg;
  
  @JSONField(name = "result")
  @ApiModelProperty(value = "返回结果")
  private List<T> result;
  
  public InvoiceResult() {
  
  }


  public InvoiceResult(List<T> result) {
    this.success = true;
    this.resultCode = "SUCCESS";
    this.result=result;
  }

  public InvoiceResult(String code, String msg) {
    this.success = false;
    this.resultCode = code;
    this.resultMsg = msg;
  }
  
  public static InvoiceResult getInvoiceResult(String code) {
    InvoiceResult invoiceResult = new InvoiceResult();
    invoiceResult.setResult(null);
    invoiceResult.setSuccess(false);
    invoiceResult.setResultCode(code);
    invoiceResult.setResultMsg("没有找到该票据");
    return invoiceResult;
  }
}
